/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package muddb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 *
 * @author keith
 */
@Entity
@Table( name = "mud_item_class_attr" )
@IdClass( MudItemClassAttrPK.class )
@NamedQueries(
  {
    @NamedQuery(
      name = "MudItemClassAttr.findByItemClassId",
      query = "SELECT m FROM MudItemClassAttr m WHERE m.itemClassId = :itemClassId" ),
    @NamedQuery(
      name = "MudItemClassAttr.findByItemClassAttrId",
      query = "SELECT m FROM MudItemClassAttr m WHERE m.itemClassAttrId = :itemClassAttrId" ),
    @NamedQuery(
      name = "MudItemClassAttr.findByItemAttrDesc",
      query = "SELECT m FROM MudItemClassAttr m WHERE m.itemAttrDesc = :itemAttrDesc" ),
    @NamedQuery(
      name = "MudItemClassAttr.findByItemAttrDfltVal",
      query = "SELECT m FROM MudItemClassAttr m WHERE m.itemAttrDfltVal = :itemAttrDfltVal" ) } )
public class MudItemClassAttr implements Serializable {
  private static final long serialVersionUID = 1L;
  
  @Id
  @Column( name = "item_class_id", nullable = false )
  private int itemClassId;
  
  @Id
  @GeneratedValue( strategy=GenerationType.SEQUENCE )
  @Column( name = "item_class_attr_id", nullable = false )
  private int itemClassAttrId;
  
  @Column( name = "item_class_attr_nm", nullable = false, length=30 )
  private String itemClassAttrName;

  @Column( name = "item_attr_desc",length=50 )
  private String itemAttrDesc;
  @Column( name = "item_attr_dflt_val",length=30 )
  private String itemAttrDfltVal;
  @OneToMany( cascade = CascadeType.ALL, mappedBy = "mudItemClassAttr" )
  private Collection<MudItemAttr> mudItemAttrCollection;
  @JoinColumn( name = "item_class_id", referencedColumnName = "item_class_id", insertable =
                                                                               false, updatable =
                                                                                      false )
  @ManyToOne
  private MudItemClass mudItemClass;


  public MudItemClassAttr() {
  }


  public MudItemClassAttr( int itemClassId, int itemClassAttrId ) {
    this.itemClassId = itemClassId;
    this.itemClassAttrId = itemClassAttrId;
  }



  public String getItemClassAttrName() {
    return itemClassAttrName;
  }


  public void setItemClassAttrName( String itemClassAttrName ) {
    this.itemClassAttrName = itemClassAttrName;
  }
  
  public String getItemAttrDesc() {
    return itemAttrDesc;
  }


  public void setItemAttrDesc( String itemAttrDesc ) {
    this.itemAttrDesc = itemAttrDesc;
  }


  public String getItemAttrDfltVal() {
    return itemAttrDfltVal;
  }


  public void setItemAttrDfltVal( String itemAttrDfltVal ) {
    this.itemAttrDfltVal = itemAttrDfltVal;
  }


  public Collection<MudItemAttr> getMudItemAttrCollection() {
    return mudItemAttrCollection;
  }


  public void setMudItemAttrCollection( Collection<MudItemAttr> mudItemAttrCollection ) {
    this.mudItemAttrCollection = mudItemAttrCollection;
  }


  public MudItemClass getMudItemClass() {
    return mudItemClass;
  }


  public void setMudItemClass( MudItemClass mudItemClass ) {
    this.mudItemClass = mudItemClass;
  }


  public void setItemClassId( int itemClassId ) {
    this.itemClassId = itemClassId;
  }


  public void setItemClassAttrId( int itemClassAttrId ) {
    this.itemClassAttrId = itemClassAttrId;
  }


  public int getItemClassId() {
    return this.itemClassId;
  }


  public int getItemClassAttrId() {
    return this.itemClassAttrId;
  }


  @Override
  public int hashCode() {
    int hash = 0;
    hash += (int) itemClassId;
    hash += (int) itemClassAttrId;
    return hash;
  }


  @Override
  public boolean equals( Object object ) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if ( !( object instanceof MudItemClassAttr ) ) {
      return false;
    }
    MudItemClassAttr other = (MudItemClassAttr) object;
    if ( this.itemClassId != other.itemClassId ) {
      return false;
    }
    if ( this.itemClassAttrId  !=  other.itemClassAttrId ) {
      return false;
    }
    return true;
  }


  @Override
  public String toString() {
    return "muddb.entities.MudItemClassAttr[itemClassId=" + itemClassId + ", itemClassAttrId=" + itemClassAttrId + "]";
  }

}
